﻿using System;

namespace 熄灯
{
    class Program
    {
        static void Main(string[] args)
        {
            DateTime start = DateTime.Now;
            Console.WriteLine("求解开始");

            // 二维灯组
            // 1表示亮着，0表示熄灭
            // 操作一个地方时，其以及四周均发生改变
            // 寻找全部熄灭的操作，没有则输出无解
            // 有解则1表示操作，0表示不操作

            //模拟中国象棋棋盘的灯组
            int[,] light = new int[,]
            {
               {1,1,1,1,1,1,1,1,1 },
               {0,0,0,0,0,0,0,0,0 },
               {0,1,0,0,0,0,0,1,0 },
               {1,0,1,0,1,0,1,0,1 },
               {0,0,0,0,0,0,0,0,0 },
               {0,0,0,0,0,0,0,0,0 },
               {1,0,1,0,1,0,1,0,1 },
               {0,1,0,0,0,0,0,1,0 },
               {0,0,0,0,0,0,0,0,0 },
               {1,1,1,1,1,1,1,1,1 }
            };


            Solution solution = new Solution(light);
            int result = solution.Solve();

            Console.WriteLine("灯组状态");
            for (int i = 0; i < solution.row; i++)
            {
                for (int j = 0; j < solution.col; j++)
                {
                    Console.Write(solution.light[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();

            Console.WriteLine("解决方案");
            solution.Print(result);


            Console.WriteLine();
            DateTime end = DateTime.Now;
            Console.WriteLine("求解结束");
            Console.WriteLine($"耗时:{(end - start).TotalMilliseconds}毫秒");
        }
    }
}
